package org.springblade.common.utils.mq;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.thierrysquirrel.annotation.CommonMessage;
import com.github.thierrysquirrel.annotation.RocketMessage;
import com.github.thierrysquirrel.annotation.StartDeliverTime;
import com.github.thierrysquirrel.core.producer.MessageSendType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * 维修预警通知
 *
 * @author zcc
 * @version 1.0
 * @date 2024/11/6 9:53
 */

@Slf4j
@Component
@RocketMessage(groupID = "GID_WX_WARN")
public class WxWarnSend {


	/**
	 * 延迟队列
	 * 维修预警消息
	 *
	 * @param startDeliverTime    时间
	 * @param message 消息体
	 * @return 数据集
	 */
	@CommonMessage(topic = "wx_warn", tag = "wx_warn_msg", messageSendType = MessageSendType.SEND_ASYNC)
	public String sendWxWarnMsg(@StartDeliverTime long startDeliverTime, String message) {
		log.info("===============实时生产消息====================", System.currentTimeMillis());
		JSONObject jsonObject = JSONObject.parseObject(message);
		log.info("发送时间:[{}],发送内容:[维修预警消息:{}]", LocalDateTime.now(), JSONObject.toJSONString(jsonObject));
		log.info("延迟的时间" + DateUtil.format(new Date(startDeliverTime), "yyyy-MM-dd HH:mm:ss"));
		return message;
	}

}
